<!DOCTYPE html>
<html>
<head>
    <title>修改住院信息--中软高科-2015</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="../Css/style.css" />
    <script type="text/javascript" src="../Js/jquery.js"></script>
    <script type="text/javascript" src="../Js/jquery.sorted.js"></script>
    <script type="text/javascript" src="../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../Js/ckform.js"></script>
    <script type="text/javascript" src="../Js/common.js"></script>
    <script type="text/javascript" src="../Js/ckeditor/ckeditor.js"></script>
 

    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
<!--    <script>-->
<!--        function getQueryString(name) {-->
<!--            var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');-->
<!--            var r = window.location.search.substr(1).match(reg);-->
<!--            if (r != null) {-->
<!--                return unescape(r[2]);-->
<!--            }-->
<!--            return null;-->
<!--        }-->
<!--        // 这样调用：-->
<!--        var queryString = getQueryString("hosR_id");-->
<!--        alert(queryString);-->
<!--        $(function () {-->
<!--            $.ajax({-->
<!--                type: "GET",-->
<!--                url: "/hos/queryById",-->
<!--                data: "hosR_id="+queryString,-->
<!--                dataType:"json",-->
<!--                success:function (vo) {-->
<!--                    let data=vo.obj;-->
<!--                    $("#hosR_id").val(data.hosR_id);-->
<!--                    $("#hosR_name").val(data.hosR_name);-->
<!--                    $("#hosR_idCar").val(data.hosR_idCar);-->
<!--                    $("#hosR_medical").val(data.hosR_medical);-->
<!--                    $("#hosR_phone").val(data.hosR_phone);-->
<!--                    data.hosR_selfPrice==1?$("#d2").prop('checked',true):$("#d1").prop('checked',true);-->
<!--                    data.hosR_sex==1?$("#s1").prop('checked',true):$("#s0").prop('checked',true);-->
<!--                    $("#hosR_age").val(data.hosR_age);-->
<!--                    data.hosR_lookDoctor=="初诊"?$("#c1").prop('checked',true):$("#c2").prop('checked',true);-->
<!--                    $("#dept").html('<option>'+data.dept.deptName+'</option>')-->
<!--                    $("#doctorName").html('<option>'+data.doctor.doctorName+'</option>')-->
<!--                    $("#hosR_remark").val(data.hosR_remark);-->
<!--                    $("#beH_nursePeople").val(data.behospital.beH_nursePeople);-->
<!--                    $("#beH_patBed").val(data.behospital.beH_patBed);-->
<!--                    $("#beH_illness").val(data.behospital.beH_illness);-->
<!--                }-->
<!--            })-->
<!--        })-->
<!--    </script>-->
    <script type="text/javascript">
    $(function () {       
		$('#backid').click(function(){
				window.location.href="index.html";
		 });
    });
    </script>
</head>
<body>
<form action="index.html" id="myForm" method="post" class="definewidth m20">
<table class="table table-bordered table-hover definewidth m10" id="tbody">
    <tr>
        <td width="10%" class="tableleft">病历号</td>
        <td><input type="text" id="id" name="id"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">姓名</td>
        <td><input type="text" id="patientName" name="patientName"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">证件类型</td>
        <td>身份证</td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">证件号</td>
        <td><input type="text" id="patientIdCard" name="patientIdCard"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">社保号</td>
        <td><input type="text" name="patientSocietyId" id="patientSocietyId"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">联系电话</td>
        <td><input type="text" id="patientPhoneNum" name="patientPhoneNum"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">是否自费</td>
        <td>
            <input type="radio" name="expenseWay" id="d1"  value="否"/>否&nbsp;&nbsp;&nbsp;
            <input type="radio" name="expenseWay" id="d2" value="是"/>是
        </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">性别</td>
        <td>
            <input type="radio" name="patientGender" id="s1" value="男" />男&nbsp;&nbsp;&nbsp;
            <input type="radio" name="patientGender" id="s0" value="女"/>女
        </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">年龄</td>
        <td><input type="text" id="patientAge" name="patientAge"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">初复诊</td>
        <td>
            <input type="radio" name="patientFirst" id="c1" value="初诊"/>初诊&nbsp;&nbsp;&nbsp;
            <input type="radio" name="patientFirst" id="c2" value="复诊"/>复诊
        </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">所挂科室</td>
        <td>
            <select id="dept">

            </select>
        </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">指定医生</td>
        <td>
            <select id="doctorName">

            </select>
        </td>
    </tr>
	<tr>
        <td width="10%" class="tableleft">备注</td>
        <td><input type="text" id="patientTip" name="patientTip"> </td>
	</tr>
    <tr>
        <td width="10%" class="tableleft">护理</td>
        <td><input type="text" name="nurse"  id="nurse"/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">床位号</td>
        <td><input type="text" id="bedNumber" name="bedNumber" /></td>
    </tr>

    <tr>
        <td width="10%" class="tableleft">病情</td>
        <td><input id="condition" name="condition"></td>
    </tr>
    <tr>
        <td colspan="2">
			<center>
				<button class="btn btn-primary" type="button" onclick="stayUpdate() ">保存</button> &nbsp;&nbsp;
                <button type="button" class="btn btn-success" name="backid" id="backid">返回列表</button>
			</center>
		</td>
    </tr>
</table>
</form>
</body>
<script>
    (function ($) {
        $.getUrlParam = function (name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]); return null;
        }
    })(jQuery);
    //dept下拉框填充
    $.ajax({
        url:"/dept/editList",
        method:"GET",
        dataType:"json",
        success:function (vo){
            var list = vo.list;
            for(var i = 0;i<list.length;i++){
                var deptName = list[i].deptName;
                var option = $("<option>").val(deptName).text(deptName);
                $("#dept").append(option);
            }
        }
    })
    //医生select下拉框填充
    $.ajax({
        url:"/Info/doctors",
        method:"GET",
        dataType:"json",
        success:function (vo){
            var list = vo.list;
            for(var i = 0;i<list.length;i++){
                var doctorName = list[i].doctorName;
                var option = $("<option>").val(doctorName).text(doctorName);
                $("#doctorName").append(option);
            }
        }
    })
    var uid = $.getUrlParam("id");

    $.ajax({
        url:"/patient/getPatientById",
        method:"GET",
        data:{
            id:uid
        },
        dataType: "json",
        success:function (vo){
            let data =vo.obj;
            let patient=data.patients[0];
            $("#id").val(patient.id)
            $("#patientName").val(patient.patientName);
            $("#patientIdCard").val(patient.patientIdCard);
            $("#patientSocietyId").val(patient.patientSocietyId);
            $("#patientPhoneNum").val(patient.patientPhoneNum);

            if(patient.expenseWay=="否"){
                $(":radio:eq(0)").attr("checked","checked");
            }else{
                $(":radio:eq(1)").attr("checked","checked");
            }
            if(patient.patientGender=="男"){
                $(":radio:eq(2)").attr("checked","checked");
            }else{
                $(":radio:eq(3)").attr("checked","checked");
            }

            $("#patientAge").val(patient.patientAge);
            if(patient.patientFirst=="初诊"){
                $(":radio:eq(4)").attr("checked","checked");
            }else{
                $(":radio:eq(5)").attr("checked","checked");
            }
            $("#dept").val(patient.patientDept);
            $("#doctorName").val(patient.doctor);
            $("#patientTip").val(patient.patientTip);
            $("#nurse").val(patient.nurse);
            $("#bedNumber").val(data.bedNumber);
            $("#condition").val(patient.condition);
        }
    })
    function stayUpdate(){
        $.ajax({
            url:"/patient/updatePatientAndBed",
            data:$("#myForm").serialize() + '&doctor=' + $('#doctorName option:selected').text() + '&patientDept=' + $('#dept option:selected').text()+'',
            method:"POST",
            success:function (vo){
                alert(vo.msg);
                toIndex();
            }
        })
    }



    function toIndex(){
        window.location.href="index.html";
    }
</script>
</html>